package br.com.timer;

public class NumberDisplay {

	private int limit;
	private int value;

	public NumberDisplay(int timeLimit) {
		limit = timeLimit;
		value = 0;
	}

	public int getValue() {
		return value;
	}

	public String getDisplayValue() {

		if (value < 10) {
			return "0" + value;
		} else {
			return "" + value;
		}
	}

	public void setValue(int replacementValue) {
		if ((replacementValue >= 0) && (replacementValue < limit)) {
			value = replacementValue;
		}
	}

	/**
	 * Increment the display value by one, rolling over to zero if the limit is
	 * reached.
	 */
	public void increment() {
		value = (value + 1) % limit;
	}

	/**
	 * decrement the display value by one, rolling over to zero if the limit is
	 * reached.
	 */
	public void decrement() {
		if (value > 0){
			value = (value - 1) % limit;
//			System.out.println("Value: "+value);
		}
		else{
			//System.out.println("zeroo");
		}
	}
}
